<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="review.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!-- 상단프레임 -->
<%@ include file="/Dmyna/head.jsp"%>

<%
	//답글을 클릭하면 검색한 결과를 출력하기 위해 다음 작업을 수행
	String parentId = request.getParameter("parent_id");
	String groupId = request.getParameter("group_id");
	ReviewWriting writing = null;
	String title = "";
	if (parentId != null) {//부모글 번호가 있으므로, 답글작업 수행
		ReviewWritingManager manager = ReviewWritingManager.getInstance();
		writing = manager.select(Integer.parseInt(parentId));
		if (writing != null) {
	title = "[re:]" + writing.getBbs_title();
		}
	}
%>

<c:set var="writing" value="<%=writing%>" />
<script type="text/javascript">
	function validate(form) {
		oEditors.getById["bbs_content"].exec("UPDATE_CONTENTS_FIELD", []);
		
		if (form.title.value == "") {
			alert("제목을 입력하세요.");
			return false;
		} else if (form.mb_no.value == "") {
			alert("로그인을 먼저 해주세요.");
			return false;
		} else if (document.getElementById("bbs_content").value == "") {
			alert("내용을 입력하세요.");
			return false;
		}
	}
</script>

<script type="text/javascript" src="../se2/js/HuskyEZCreator.js" charset="utf-8"></script>

<form action="/MyReviewWrite.do" method="post" enctype="multipart/form-data" onsubmit="return validate(this)">
	<input type="hidden" name="level_id" value="${writing.level_id + 1 }" />
	<input type="hidden" name="order_id" value="${writing.order_id + 1 }" />
	<c:if test="${! empty param.group_id }">
	<input type="hidden" name="group_id" value="${param.group_id }" />
	</c:if>
	<c:if test="${! empty param.parent_id }">
	<input type="hidden" name="parent_id" value="${param.parent_id }" />
	</c:if>
	
	<input type="hidden" name="mb_no" value="${sessionScope.SESSION_MB_NO }" />

	<table width="900" align=center cellpadding=0 cellspacing=0>
		<tr>
			<td>

				<div
					style="border:1px solid #ddd; height:34px; background:url(${WEB_ROOT }/img/bbs/title_bg.gif) repeat-x;">
					<div
						style="font-weight: bold; font-size: 14px; margin: 7px 0 0 10px;">
						::
						구매 후기 게시판
						::
					</div>
				</div>
				<div style="height:3px; background:url(${WEB_ROOT }/img/bbs/title_shadow.gif) repeat-x; line-height:1px; font-size:1px;"></div>

				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<colgroup width=90>
					<colgroup width=''>
					<tr>
						<td colspan="2" style="background:url(${WEB_ROOT }/img/bbs/title_bg.gif) repeat-x; height:3px;"></td>
					</tr>
					
					<tr>
						<td colspan=2 height=1 bgcolor=#e7e7e7></td>
					</tr>

					<tr>
						<td class=write_head align="center" height="30">제 목</td>
						<td><input class='ed' style='width: 98%; word-break: break-all;' name="title" id="wr_subject" itemname="제목"  value="<%= title %>"></td>
					</tr>
					<tr>
						<td colspan=2 height=1 bgcolor=#e7e7e7></td>
					</tr>

					<tr>
						<td class=write_head align="center">내 용</td>
						<td>
						<textarea name="bbs_content" id="bbs_content" rows="20" cols="145"></textarea>
          				</td>
					</tr>
					<tr>
						<td colspan=2 height=1 bgcolor=#e7e7e7></td>
					</tr>
					<tr>
						<td class=write_head align="center" height="30">이미지</td>
						<td><input class='ed' style="width: 50%;" type="file" name="image_name" id="image_name"  /></td>
					</tr>
					<tr>
						<td colspan=2 height=1 bgcolor=#e7e7e7></td>
					</tr>

					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td>
							<div style="clear: both; height: 30px;">
							<div style="float: right; margin-top: 6px;">
							<input type="image" id="btn_submit" src="${WEB_ROOT }/img/bbs/btn_write.gif" border=0 accesskey='s'>&nbsp; 
							<a href="${WEB_ROOT }/review/MyReviewList.jsp">
							<img id="btn_list"src="${WEB_ROOT }/img/bbs/btn_list.gif" border=0></a>
							</div>
							</div>
							</td>
						</tr>
					</table>
				</table>
			</td>
		</tr>
	</table>
</form>

<script type="text/javascript">

var oEditors = [];

nhn.husky.EZCreator.createInIFrame({

    oAppRef: oEditors,

    elPlaceHolder: "bbs_content",

    sSkinURI: "../se2/SmartEditor2Skin.html",

    fCreator: "createSEditor2"

});

</script>

<!-- 하단프레임 -->
<%@ include file="/Dmyna/tail.jsp"%>
